package com.design.graduation.asdemo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;

import com.design.graduation.asdemo.R;
import com.design.graduation.asdemo.base.ActionBarActivity;
import com.igexin.sdk.PushManager;
import com.orhanobut.logger.Logger;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

/**
 * Created by lijinyuan on 16/2/20.
 */

@EActivity(R.layout.activity_personal)
public class PersonalActivity extends ActionBarActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        PushManager.getInstance().initialize(this.getApplicationContext());
    }

    private int[] img = new int[]{
            R.drawable.appintro1,
            R.drawable.appintro2,
            R.drawable.appintro3,
            R.drawable.appintro4,
    };
    private int imgResID = 0;


    @ViewById(R.id.personal_bg)
    ImageView imageView;

    @AfterViews
    public void initView() {
        handler = new Handler();
        setTheme(R.style.AppTheme);
        initNormalActionBar();
        setTitle("个人中心");
        setImgAnimation();
    }

    private void setImgAnimation() {
        handler.post(animationHandler);


    }

    Handler handler = new Handler();
    Runnable animationHandler = new Runnable() {
        @Override
        public void run() {
            imageView.setImageResource(img[imgResID++ % img.length]);
            handler.postDelayed(animationHandler, 5000);

            Animation animation = new ScaleAnimation(0.5f, 1.0f, 0.5f, 1.0f);
            animation.setDuration(5000);
            animation.setRepeatCount(-1);
            imageView.startAnimation(animation);
        }
    };


    public void toWriteDetails(View view) {
        startActivity(new Intent(PersonalActivity.this, WriteDetailsActivity.class));
    }

    public void toSolicit(View view) {
        startActivity(new Intent(PersonalActivity.this, SolicitingActivity_.class));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
